package com.dididoctor.patient.Activity.Usercentre.Evaluate;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.TextView;

import com.dididoctor.patient.Activity.Service.ServiceDetail.ServiceDetailActivity;
import com.dididoctor.patient.MV.adapter.CommonAdapter;
import com.dididoctor.patient.MV.adapter.ViewHolder;
import com.dididoctor.patient.R;
import com.dididoctor.patient.Utils.LoaderImage;
import com.dididoctor.patient.Utils.UserHeadImage;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;

import java.util.List;

/**
 * Created by Administrator on 2016/4/8.
 */
public class UserEvaluateAdapter extends CommonAdapter<UserEvaluate> {

    private UserHeadImage headImage;
    private TextView mtvName, mTvHospital, mTvdiseName, mTvLevel, mTvRemark;
    private LoaderImage loaderImage;
    private Context mcontext;

    public UserEvaluateAdapter(Context context, List<UserEvaluate> datas) {
        super(context, datas, R.layout.item_user_evaluate);
        this.mcontext = context;
        loaderImage = new LoaderImage(context);
    }

    @Override
    public void convert(int position, ViewHolder helper, UserEvaluate item) {
        mtvName = helper.getView(R.id.tv_name);
        mTvHospital = helper.getView(R.id.tv_hospital);
        mTvdiseName = helper.getView(R.id.tv_dise);
        mTvLevel = helper.getView(R.id.tv_level);
        mTvRemark = helper.getView(R.id.tv_remark);

        mtvName.setText(item.getName());
        mTvHospital.setText(item.getHospital());
        mTvdiseName.setText("治疗疾病：" + item.getDiseName());
        if ("5".equals(item.getPoint())) {
            mTvLevel.setText("评价:" + "满意");
        } else if ("4".equals(item.getPoint())) {
            mTvLevel.setText("评价:" + "一般");
        } else {
            mTvLevel.setText("评价:" + "不满意");
        }

        mTvRemark.setText(item.getRemark());

        headImage = helper.getView(R.id.user_head_image);

        loaderImage.load(headImage, item.getPicUrl(), new ImageLoadingListener() {
            @Override
            public void onLoadingStarted(String s, View view) {
                headImage.setImageResource(R.drawable.img_doctordefault);
            }

            @Override
            public void onLoadingFailed(String s, View view, FailReason failReason) {
                headImage.setImageResource(R.drawable.img_doctordefault);
            }

            @Override
            public void onLoadingComplete(String s, View view, Bitmap bitmap) {

            }

            @Override
            public void onLoadingCancelled(String s, View view) {

            }
        });

        helper.getConvertView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            }
        });

    }
}
